/**
 * 
 */
package edu.buu.refectory.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.buu.refectory.dao.UserMapper;
import edu.buu.refectory.domain.User;
import edu.buu.refectory.utils.MD5Util;

/**
 * @author Bruce<br>
 * @version 1.0<br>
 * @CreateDate 30 Apr 2016 <br>
 */
@Service
public class UserService {
	
	@Autowired
	private UserMapper dao;
	/**
	 * @param username
	 * @return
	 */
	public List<User> getList(Map map) {
		return dao.getList(map);
	}
	/**
	 * @param username
	 * @return
	 */
	public List<User> getByUsername(String username) {
		return  dao.getByUsername(username);
	}
	/**
	 * @param user
	 * @return
	 */
	public User create(User user) {
		try {
			user.setuKey(MD5Util.encrypt(user.getuKey(), user.getuName()));
			user.setuBalance(0);
		} catch (Exception e) {
			e.printStackTrace();
		}
		dao.insert(user);
		return user;
	}

}
